Migrate internal diagnostics to tracing
#655
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The
tracing
crate and related libraries provide an interface for Rustlibraries and applications to emit and consume structured, contextual,
and async-aware diagnostic information.
tracing
is maintained by theTokio project and is becoming widely adopted by other libraries in the
stack Warp uses, such as
hyper
,h2
, andtonic
and in otherparts of the broader Rust ecosystem.
Tracing supports multiple integrations with the
log
crate. An adaptercan convert
log::Record
s intotracing::Event
s to be consumed by atracing
subscriber, and atracing
feature flag can be enabled toemit
log
records fromtracing
's macros.However,
tracing
's system for filtering what spans and events shouldbe recorded is more efficient than the
log
crate's filtering in manycases, since it allows filtering decisions to be cached at the callsite,
avoiding a call to a filtering function that may, for example, perform
string matching. This benefit is only available when events are emitted
natively from
tracing
's macros, rather than converted by an adapterfrom
log::Record
s, becauselog
's records lack static callsites.This branch migrates Warp's internal diagnostics to use
tracing
ratherthan
log
. In general, thetracing
macros are drop-in compatible withlog
, so the migration only requires changing what crate the macros areimported from. Tracing's "log" feature flag is enabled, causing all the
tracing
macros to emitlog
records if notracing
subscriber hasbeen set. This means that the logs currently emitted for
log
usersshould be unchanged, while
tracing
users should see small performanceimprovements. I've also added a few
tracing
spans to provide contextfor some of the events Warp emits.
Future work could involve:
tracing
's structured key-value fields rather than textual messagesSigned-off-by: Eliza Weisman [email protected]